home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
simcode.arc
/
UTIL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1984-10-14
|
3KB
|
119 lines
{$debug-}
{$symtab-,$pagesize:86,$linesize:132,
$title:'UTIL.PAS -- games utilities'}
{$debug-}
module util;
var
[static] seed : word;
starttime : integer;
elasped : integer;
is_stopped : boolean;
value elasped := 0;
is_stopped := true;
function uaddok(a,b:word;
var c:word) : boolean;
external;
function umulok(a,b:word;
var c:word) : boolean;
external;
procedure time(var s: string);
external;
function rand(x : integer) : integer [public];
var
a,b : word;
trash : boolean;
s : word;
r : integer;
begin
a := 46269;
b := 13849;
s := seed;
trash := umulok(a,s,seed);
s := seed;
trash := uaddok(b,s,seed);
r := ord(seed-32768);
if (r < 0) then r := -r;
rand := (r mod x) + 1;
end;
procedure srand [public];
var
trashtime : string(10);
begin
time(trashtime);
seed := (wrd(trashtime[2])-48)*3600+(wrd(trashtime[4])-48)*600+ (wrd(
trashtime[5])-48)*60+(wrd(trashtime[7])-48)*10+(wrd(trashtime[8])
-48);
elasped := 0;
end;
procedure startclock [public];
var
trashtime : string(10);
begin
time(trashtime);
starttime := (ord(trashtime[2])-48)*3600+(ord(trashtime[4])-48)*600+ (
ord(trashtime[5])-48)*60+(ord(trashtime[7])-48)*10+(ord(
trashtime[8])-48);
starttime := starttime - elasped;
elasped := 0;
is_stopped := false;
end;
procedure stopclock [public];
var
trashtime : string(10);
trashint : integer;
begin
if (is_stopped = false) then begin
time(trashtime);
trashint := (ord(trashtime[2])-48)*3600+(ord(trashtime[4])-48)*600+
(ord(trashtime[5])-48)*60+(ord(trashtime[7])-48)*10+(ord(
trashtime[8])-48);
elasped := trashint - starttime;
is_stopped := true;
end;
end;
function readclock : integer [public];
var
currtime : integer;
trashtime : string(10);
begin
if (is_stopped = false) then begin
time(trashtime);
currtime := (ord(trashtime[2])-48)*3600+(ord(trashtime[4])-48)*600+
(ord(trashtime[5])-48)*60+(ord(trashtime[7])-48)*10+(ord(
trashtime[8])-48);
readclock := currtime - starttime;
end
else readclock := elasped;
end;
procedure timepenalty(pen : integer);
begin
if (is_stopped = false) then starttime := starttime - pen
else elasped := elasped + pen;
end;
end.